package com.dai.wechat.job;

import com.dai.wechat.util.Pusher;
import com.dai.wechat.util.Result;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;



@Configuration
// 开启定时任务
@EnableScheduling
public class SaticScheduleTask {


    private final String TENG_OPENID = "oiX7p5xMzG38gozbHzGUCoDX-vUM";

    //@Scheduled(cron = "0 * 13 * * ? ")
    // 3.添加定时任务(每天早上七点半)
    @Scheduled(cron = "0 30 7 * * ?")
    private void configureTasks() {

        Result<String> push = Pusher.push(TENG_OPENID,Pusher.GOODMORNING_TEMPLATEID);
        if("200".equals(push.getCode())){
            //System.out.println("发送早安消息成功！");
        }else{
            System.out.println("早安消息发送失败，原因: " + push.getMessage());
        }

    }

    // 定时任务：从七点开始，每三小时执行一次
    @Scheduled(cron = "0 0 7/3 * * ? ")
    private void drinkWaterTasks() {

        Result<String> push = Pusher.push(TENG_OPENID,Pusher.DRINK_TEMPLATEID);
        if("200".equals(push.getCode())){
            //System.out.println("发送喝水成功！");
        }else{
            System.out.println("喝水消息发送失败，原因: " + push.getMessage());
        }

    }
}